package com.zhijiaoyun.dao;

import com.zhijiaoyun.dao.core.IBaseDao;
import com.zhijiaoyun.model.News;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author shisfish
 * @date 2017/6/6
 */
public interface INewsDao extends IBaseDao<News> {
    /**
     * get by title
     *
     * @param title
     * @return
     */
    News selectBytitle(String title);

    /**
     * get by title not id
     *
     * @param newsId
     * @param title
     * @return
     */
    News selectByTitleNotNewsId(@Param("newsId") Long newsId, @Param("title") String title);

    /**
     * count by params
     *
     * @param title
     * @param ids
     * @return
     */
    int countByParams(@Param("title") String title, @Param("ids") List<Long> ids);

    /**
     * page by params
     *
     * @param beginIndex
     * @param pageSize
     * @param title
     * @param ids
     * @return
     */
    List<News> pageByParams(@Param("beginIndex") int beginIndex, @Param("pageSize") int pageSize,
                            @Param("title") String title, @Param("ids") List<Long> ids);

    /**
     * get title by id
     *
     * @param newsId
     * @return
     */
    String selectTitleByNewsId(Long newsId);

    /**
     * count hot by title and ids
     *
     * @param title
     * @param ids
     * @return
     */
    int countByParamsHot(@Param("title") String title, @Param("ids") List<Long> ids);

    /**
     * 分页 热点新闻
     *
     * @param beginIndex
     * @param pageSize
     * @param title
     * @param ids
     * @return
     */
    List<News> pageByParamsHot(@Param("beginIndex") int beginIndex, @Param("pageSize") int pageSize,
                               @Param("title") String title, @Param("ids") List<Long> ids);

    /**
     * 添加浏览数
     *
     * @param newsId
     */
    void addViewNum(Long newsId);

    /**
     * 添加点赞数
     *
     * @param newsId
     */
    void addPraiseNum(Long newsId);

    /**
     * 添加评论数
     *
     * @param newsId
     */
    void addCommentNum(Long newsId);

    /**
     * 获取全部数量
     *
     * @return
     */
    int countAll();
}